package com.lwg.datastructure.CommonSelectMethod;

/**
 * @author: lwg
 * @Date: 2022/4/23 0:03
 * @Description: 直接查找
 */
public class DirectSelect {
    
    public static void main(String[] args) {
        int[] arr = {3, -1, 5, 4, 6, 1, 10, 20};
        System.out.println(directSelect(arr, 4));
    }
    
    private static int directSelect(int[] arr, int key) {
        for (int i = 0; i < arr.length; i++) {
            if (arr[i]==key){
                return i;
            }
        }
        return -1;
    }
}
